package com.project.petLossSystem.service.impl;

import com.project.petLossSystem.mapper.ContactItemMapper;
import com.project.petLossSystem.po.ContactItem;
import com.project.petLossSystem.service.ContactItemService;
import com.project.petLossSystem.util.PageQueryUtil;
import com.project.petLossSystem.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ContactItemServiceImpl implements ContactItemService {
    @Autowired
    private ContactItemMapper contactItemMapper;
    @Override
    public boolean insertItem(ContactItem contactItem) {
        return contactItemMapper.insertItem(contactItem) > 0;
    }

    @Override
    public PageResult getItemPage(PageQueryUtil pageQueryUtil) {
        List<ContactItem> contactItems = contactItemMapper.itemList(pageQueryUtil);
        long total = contactItemMapper.itemCount(pageQueryUtil);
        return new PageResult(total, pageQueryUtil.getRows(), pageQueryUtil.getPage(), contactItems);
    }

    @Override
    public long getItemCountToday() {
        return contactItemMapper.getCountToday();
    }
}
